home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / nut2.cls < prev    next >
Encoding:
Visual Basic class definition  |  2005-03-10  |  68.0 KB  |  1,808 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "Detail"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. Option Explicit
  15. '/******************************************************************/
  16. '/*                                                                */
  17. '/*                      TurboCAD for Windows                      */
  18. '/*                   Copyright (c) 1993 - 2001                    */
  19. '/*             International Microcomputer Software, Inc.         */
  20. '/*                            (IMSI)                              */
  21. '/*                      All rights reserved.                      */
  22. '/*                                                                */
  23. '/******************************************************************/
  24.  
  25. 'DBAPI constants
  26. Const gkGraphic = 11
  27. Const gkArc = 2
  28. Const gkText = 6
  29. Const gfCosmetic = 128&
  30.                                                                                                                                                                                              
  31. 'Useful math constants
  32. Const Pi# = 3.14159265
  33.  
  34. 'Real variant types!
  35. Const typeEmpty = 0
  36. Const typeInteger = 2
  37. Const typeLong = 3
  38. Const typeSingle = 4
  39. Const typeDouble = 5
  40. Const typeCurrency = 6
  41. Const typeDate = 7
  42. Const typeString = 8
  43. Const typeObject = 9
  44. Const typeBoolean = 11
  45. Const typeVariant = 12
  46. Const typeIntegerEnum = typeInteger + 100
  47. Const typeLongEnum = typeLong + 100
  48. Const typeStringEnum = typeString + 100
  49.  
  50. 'Stock property pages
  51. Const ppStockPen = 1
  52. Const ppStockBrush = 2
  53. Const ppStockText = 4
  54. Const ppStockInsert = 8
  55. Const ppStockViewport = 16
  56. Const ppStockAuto = 32
  57.  
  58. 'Property Ids
  59. Const idNutType = 1
  60. Const idDiameter = 2
  61. Const idLength = 3
  62. Const idView = 4
  63. Const idLengthThread = 5
  64.  
  65. 'Property enums
  66.  
  67.  
  68. 'Number of properties, pages, wizards
  69. Const NUM_PROPERTIES = 5
  70. Const NUM_PAGES = 1
  71. Const NUM_WIZARDS = 0
  72. Private PColor As Long
  73. Private BColor As Long
  74.  
  75.  
  76. Private Sub Class_Initialize()
  77.     'Initialize class variables
  78. End Sub
  79.  
  80. 'Returns the user-visible description of this RegenMethod
  81. Public Property Get Description() As String
  82.     Description = "Nut"
  83. End Property
  84.  
  85. 'Returns the persistent class id for this RegenMethod's property section
  86. Public Property Get ClassID() As String
  87.     ClassID = "{FDB6F1C3-9631-11d1-A40A-0000B465872B}"
  88.  
  89. End Property
  90.  
  91. 'Retrieve types and names
  92. Public Function GetPropertyInfo(Names As Variant, Types As Variant, _
  93.     IDs As Variant, Defaults As Variant) As Long
  94.     ReDim Names(NUM_PROPERTIES), Types(NUM_PROPERTIES), _
  95.         IDs(NUM_PROPERTIES), Defaults(NUM_PROPERTIES)
  96.     Names(0) = "NutType"
  97.     Types(0) = typeString
  98.     IDs(0) = idNutType
  99.     Defaults(0) = "HexNut"
  100.         
  101.     Names(1) = "DiameterN"
  102.     Types(1) = typeDouble
  103.     IDs(1) = idDiameter
  104.     Defaults(1) = 1#
  105.  
  106.     Names(2) = "LengthN"
  107.     Types(2) = typeDouble
  108.     IDs(2) = idLength
  109.     Defaults(2) = 3#
  110.     
  111.     Names(3) = "NutView"
  112.     Types(3) = typeString
  113.     IDs(3) = idView
  114.     Defaults(3) = "Front"
  115.    
  116.     Names(4) = "LengthThreadN"
  117.     Types(4) = typeDouble
  118.     IDs(4) = idLengthThread
  119.     Defaults(4) = 0#
  120.    
  121.    GetPropertyInfo = NUM_PROPERTIES
  122. End Function
  123.  
  124. 'Get the number of property pages supporting this RegenMethod
  125. Public Function GetPageInfo(ByVal AGraphic As Object, StockPages As Long, _
  126.     Names As Variant) As Long
  127.     ReDim Names(NUM_PAGES)
  128.  
  129.     'Need the form
  130. '    Load frmSample
  131. '    Names(0) = frmSample.Caption
  132. '    Unload frmSample
  133.     Names(0) = LoadResString(101)
  134.     StockPages = ppStockBrush + ppStockPen + ppStockAuto
  135.     GetPageInfo = NUM_PAGES
  136. End Function
  137.  
  138. Public Function GetWizardInfo(Names As Variant) As Long
  139.     ReDim Names(NUM_WIZARDS)
  140.     GetWizardInfo = NUM_WIZARDS
  141. End Function
  142.  
  143. 'Enumerate the names and values of a specified property
  144. Public Function GetEnumNames(ByVal PropID As Long, Names As Variant, Values As Variant) As Long
  145.  
  146. End Function
  147.  
  148. Public Function PageControls(ByVal ThisRegenMethod As Object, ByVal Graphic As Object, ByVal PageNumber As Long, ByVal SaveProperties As Boolean) As Boolean
  149.         'Set up error function
  150.         On Error GoTo Failed
  151.         Dim i%
  152.         Dim Diameter#, Length#, LThread#
  153.         If SaveProperties Then
  154.             'OK button on property page was clicked
  155.             'Form is still loaded
  156.             With frmSample
  157.                 'Need On Error statement for the case where you have
  158.                 'RRect Turbo Shape and ahother "shape" selected
  159.                 On Error Resume Next
  160.                 'When the property page is closed, transfer the numeric
  161.                 'Diameter value from the TextBox to the Graphic
  162.                 'Get the value as a double-precision number
  163.                 TypeN = .List1.Text
  164.                 ViewN = .List2.Text
  165.                 Diameter# = CDbl(.txtdd.Text)
  166.                 LThread# = CDbl(.txtLenThread.Text)
  167.                 
  168.                 'Make sure it's between 0 and 100
  169.                 If Diameter# < 0# Then Diameter# = 1#
  170.                 If Diameter# > 3# Then Diameter# = 3#
  171.                 
  172.                 'Set the roundness property value in the Graphic
  173.                 Graphic.Properties("DiameterN") = Diameter#
  174.                 Graphic.Properties("NutType") = TypeN
  175.                 Graphic.Properties("NutView") = ViewN
  176.                 Graphic.Properties("LengthThreadN") = LThread
  177.                 
  178.             End With
  179.         Else
  180.             'Property page is about to be opened
  181.             'Make sure the form is loaded
  182.             Load frmSample
  183.             With frmSample
  184.             
  185.                 'If more than one RRect is selected and they do not
  186.                 'have the same properties, don't set up this field
  187.                 On Error GoTo NoRType
  188.  
  189.                 'When the property page is opening, transfer the numeric
  190.                 'roundness value from the Graphic to the TextBox
  191.                 'Get the roundness property value from the Graphic
  192.                 Diameter# = Graphic.Properties("DiameterN")
  193.                 TypeN = Graphic.Properties("NutType")
  194.                 ViewN = Graphic.Properties("NutView")
  195.                 LThread = Graphic.Properties("LengthThreadN")
  196.             'Set the TextBox control's text
  197.                 .txtdd.Text = Diameter#
  198.                 .List1.Text = TypeN
  199.                 .List2.Text = ViewN
  200.                 .txtLenThread.Text = LThread
  201. NoRType:
  202.             End With
  203.         End If
  204.  
  205.         PageControls = True
  206.         Exit Function
  207.  
  208. Failed:
  209.         'For debugging purposes, report that an error occurred
  210.         If Err.Number <> 0 Then
  211.             MsgBox "Error in PageControls: " & Err.Description
  212.         End If
  213.  
  214.         'Return false if an error occurred
  215.         PageControls = False
  216. End Function
  217.  
  218. Public Function PageDone(ByVal ThisRegenMethod As Object, Optional PageNumber As Variant)
  219.         'Done with form
  220.         Unload frmSample
  221. End Function
  222.  
  223. Public Function PropertyPages(ByVal ThisRegenMethod As Object, Optional PageNumber As Variant) As Boolean
  224.     With frmSample
  225.         .Show vbModal
  226.         PropertyPages = Not .DialogCanceled
  227.     End With
  228. End Function
  229.  
  230. Public Function Wizard(ByVal ThisRegenMethod As Object, Optional WizardNumber As Variant) As Boolean
  231.     Wizard = False
  232. End Function
  233.  
  234. 'Called when vertex has been moved, or other geometry change
  235. Public Function OnGeometryChanged(ByVal Graphic As Object, ByVal GeomID As Long, paramOld As Variant, paramNew As Variant)
  236.     'Do nothing
  237.     'Regen Graphic
  238. End Function
  239.  
  240. 'Called when vertex is moved, or other geometry change
  241. Public Function OnGeometryChanging(ByVal Graphic As Object, ByVal GeomID As Long, paramOld As Variant, paramNew As Variant) As Boolean
  242.     'OK to continue with change
  243.     OnGeometryChanging = True
  244. End Function
  245.  
  246. Public Function OnNewGraphic(ByVal grfThis As Object, ByVal boolCopy As Boolean) As Boolean
  247.     If boolCopy Then
  248.         'Vertices are already added for us...
  249.         OnNewGraphic = True
  250.         Exit Function
  251.     End If
  252.  
  253.     On Error GoTo Failed
  254.     'New Graphic being created
  255.     'X, Y, Z, PenDown, Selectable, Snappable, Editable, Linkable
  256.     'First Vertex is "first point of axis"
  257.     grfThis.Vertices.Add 0#, 0, 0#, False, True, True, True, True, False
  258.     
  259.     'Second Vertex is "Second point of axis"
  260.     
  261.     grfThis.Vertices.Add 3#, 0, 0#, False, True, True, True, True, False
  262.     grfThis.Properties("PenColor") = RGB(0, 0, 0)
  263.     grfThis.Properties("BrushColor") = RGB(255, 255, 255)
  264.     
  265.     OnNewGraphic = True
  266.     Exit Function
  267.  
  268. Failed:
  269.     'Return false on failure
  270.     OnNewGraphic = False
  271. End Function
  272.  
  273. 'Function called whenever a copy of a graphic is being made
  274. Public Function OnCopyGraphic(ByVal grfCopy As Object, ByVal grfSource As Object) As Boolean
  275.     'Return false on failure
  276.     OnCopyGraphic = True
  277. End Function
  278.  
  279. 'Notification function called after graphic property is saved
  280. Public Function OnPropertyChanged(ByVal Graphic As Object, ByVal PropID As Long, _
  281.         ValueOld As Variant, ValueNew As Variant)
  282.     'Do nothing
  283. End Function
  284.  
  285. 'Notification function called when graphic property is saved
  286. Public Function OnPropertyChanging(ByVal Graphic As Object, ByVal PropID As Long, _
  287.         ValueOld As Variant, ValueNew As Variant) As Boolean
  288.     'OK to proceed
  289.     OnPropertyChanging = True
  290. End Function
  291.  
  292. 'Notification function called when graphic property is retrieved
  293. Public Function OnPropertyGet(ByVal Graphic As Object, ByVal PropID As Long)
  294.     'Do nothing
  295. End Function
  296.  
  297. 'Called when we need to update our object
  298. Public Function Regen(ByVal grfThis As Object)
  299.         'Setup error handler
  300.         On Error GoTo Failed
  301.  
  302.         'Set up lock (prevent recursion)
  303.         Dim LockCount&
  304.         LockCount& = grfThis.RegenLock
  305.         PColor = grfThis.Properties("PenColor")
  306. ''AALB problem with load old files
  307. ' AALB try to fix bug with reading files from TC v6.5 (problem is that some sdk regens
  308. ' has Type = 7(Group, must be GRAPHIc (11))
  309. On Error Resume Next
  310. Err.Clear
  311.         BColor = grfThis.Properties("BrushColor")
  312.         If Err.Number <> 0 Then
  313.             BColor = RGB(255, 255, 255)
  314.             Err.Clear
  315.         End If
  316.         
  317.         
  318.         'Setup error handler (make sure lock is removed)
  319.         On Error GoTo FailedLock
  320.         If LockCount& = 0 Then
  321.             'Delete any previous cosmetic children
  322.             grfThis.Graphics.Clear gfCosmetic
  323.  
  324.             TypeN = grfThis.Properties("NutType")
  325.             ViewN = grfThis.Properties("NutView")
  326.  
  327.             Dim dd#
  328.                 dd = grfThis.Properties("DiameterN")
  329.                 
  330.             Dim LThread#
  331.                 LThread = grfThis.Properties("LengthThreadN")
  332. Dim X00#, Y00#, X01#, Y01#
  333.             With grfThis.Vertices
  334.                 X00 = .Item(0).X
  335.                 Y00 = .Item(0).Y
  336.                 X01 = .Item(1).X
  337.                 Y01 = .Item(1).Y
  338.                 If Abs(X00 - X01) < 0.001 And Abs(Y00 - Y01) < 0.001 Then
  339.                     .Item(1).X = X00 + 1#
  340.                     .Item(1).Y = Y00
  341.                 End If
  342.             End With
  343. '##########################################################
  344.             If TypeN = "HexNut" Then
  345.                 Call HexNut(grfThis, dd, LThread)
  346.             End If
  347.                    
  348.             If TypeN = "HexFlangeNut" Then
  349.                 Call HexFlangeNut(grfThis, dd, LThread)
  350.             End If
  351.             
  352.             If TypeN = "HexSlottedNut" Then
  353.                 Call HexSlottedNut(grfThis, dd, LThread)
  354.             End If
  355.             
  356.             If TypeN = "LowCrownNut" Then
  357.                 Call LowCrownNut(grfThis, dd, LThread)
  358.             End If
  359.  
  360.             If TypeN = "SquareNut" Then
  361.                 Call SquareNut(grfThis, dd, LThread)
  362.             End If
  363.  
  364.             'Add visible child Graphics
  365.         End If
  366.  
  367.         grfThis.RegenUnlock
  368.         Exit Function
  369.  
  370. FailedLock:
  371.         'Remove lock
  372.         grfThis.RegenUnlock
  373.  
  374. Failed:
  375. End Function
  376.  
  377. Public Function Draw(ByVal grfThis As Object, ByVal view As Object, Optional mat As Variant) As Boolean
  378.     'Return True if we did the redraw (no further processing necessary, no children will be drawn).
  379.     'Since this is just a test, we return False to let TurboCAD do the drawing operation.
  380.     Draw = False
  381. End Function
  382. Private Function Angle(sinb As Double, cosb As Double) As Double
  383.  
  384.         If Abs(cosb) < 0.0001 Then
  385.             If sinb > 0 Then
  386.                 Angle = Pi / 2
  387.             Else
  388.                 Angle = 3 * Pi / 2
  389.             End If
  390.         Else
  391.             If sinb >= 0 And cosb > 0 Then Angle = Atn(sinb / cosb)
  392.             If sinb >= 0 And cosb < 0 Then Angle = Pi + Atn(sinb / cosb)
  393.             If sinb < 0 And cosb < 0 Then Angle = Pi + Atn(sinb / cosb)
  394.             If sinb < 0 And cosb > 0 Then Angle = 2 * Pi + Atn(sinb / cosb)
  395.         End If
  396. End Function
  397.  
  398.  
  399. Private Sub HexNut(Gr As Graphic, dd As Double, LThread As Double)
  400. Dim D#, H#, S#, K#, del#
  401.         D = 1.84 * dd
  402.         H = 1# * dd
  403.         S = D * Cos(Pi / 6)
  404.         K = D / 2 * (1 - Cos(Pi / 6)) * Tan(Pi / 6)
  405.         del = 0.15 * dd
  406. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  407. Dim Salp#, Calp#, L#
  408. Dim X00#, Y00#, X01#, Y01#
  409.         With Gr.Vertices
  410.             X00 = .Item(0).X
  411.             Y00 = .Item(0).Y
  412.             X01 = .Item(1).X
  413.             Y01 = .Item(1).Y
  414.             L = Sqr((X01 - X00) * (X01 - X00) + (Y01 - Y00) * (Y01 - Y00))
  415.             Salp = (Y01 - Y00) / L
  416.             Calp = (X01 - X00) / L
  417.         End With
  418.         If Abs(H - L) > 0.0001 Then
  419.             X01 = X00 + H * Calp
  420.             Y01 = Y00 + H * Salp
  421.             With Gr.Vertices
  422.                 .Item(1).X = X01
  423.                 .Item(1).Y = Y01
  424.                 L = H
  425.             End With
  426.         End If
  427. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  428.  
  429. Dim x0(26)
  430. Dim y0(26)
  431. Dim X(26)
  432. Dim Y(26)
  433.        
  434.        x0(1) = 0#
  435.        y0(1) = S / 2#
  436.        
  437.        x0(2) = x0(1)
  438.        y0(2) = -y0(1)
  439.        
  440.        x0(3) = K
  441.        y0(3) = D / 2#
  442.        
  443.        x0(4) = x0(3)
  444.        y0(4) = -y0(3)
  445.        
  446.        x0(5) = H - K
  447.        y0(5) = D / 2
  448.        
  449.        x0(6) = x0(5)
  450.        y0(6) = -y0(5)
  451.               
  452.        x0(7) = H
  453.        y0(7) = S / 2#
  454.        
  455.        x0(8) = x0(7)
  456.        y0(8) = -y0(7)
  457.        
  458.        x0(9) = x0(3)
  459.        y0(9) = D / 4
  460.        
  461.        x0(10) = x0(9)
  462.        y0(10) = -y0(9)
  463.        
  464.        x0(11) = x0(5)
  465.        y0(11) = D / 4#
  466.        
  467.        x0(12) = x0(11)
  468.        y0(12) = -y0(11)
  469.        
  470.        x0(13) = 0#
  471.        y0(13) = 3 * D / 8
  472.        
  473.        x0(14) = x0(13)
  474.        y0(14) = -y0(13)
  475.        
  476.        x0(15) = H
  477.        y0(15) = 3 * D / 8
  478.        
  479.        x0(16) = x0(15)
  480.        y0(16) = -y0(15)
  481.        
  482.        x0(17) = 0
  483.        y0(17) = 0
  484.        
  485.        x0(18) = H
  486.        y0(18) = 0#
  487.        
  488. ' Thread
  489.        x0(19) = H
  490.        y0(19) = dd / 2
  491.        
  492.        x0(20) = x0(19)
  493.        y0(20) = -y0(19)
  494.        
  495.        x0(21) = H + LThread - del
  496.        y0(21) = dd / 2
  497.        
  498.        x0(22) = x0(21)
  499.        y0(22) = -y0(21)
  500.        
  501.        x0(23) = H + LThread
  502.        y0(23) = dd / 2 - del
  503.        
  504.        x0(24) = x0(23)
  505.        y0(24) = -y0(23)
  506.        
  507.        x0(25) = H
  508.        y0(25) = dd / 2 - del
  509.        
  510.        x0(26) = x0(25)
  511.        y0(26) = -y0(25)
  512.        
  513. Dim i%
  514.        For i = 1 To 26
  515.           X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  516.           Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  517.        Next i
  518. Dim GrChild As Graphic
  519.             'Add child Graphics
  520.         If ViewN = "Front" Then
  521.             If LThread > 0.01 * dd Then
  522.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  523.                           GrChild.Cosmetic = True
  524.                 With GrChild.Vertices
  525.                     .Add X(19), Y(19), 0, True, True, False, False, False, False
  526.                     .Add X(21), Y(21), 0, True, True, False, False, False, False
  527.                     .Add X(23), Y(23), 0, True, True, False, False, False, False
  528.                     .Add X(24), Y(24), 0, True, True, False, False, False, False
  529.                     .Add X(22), Y(22), 0, True, True, False, False, False, False
  530.                     .Add X(20), Y(20), 0, True, True, False, False, False, False
  531.                     .Add X(19), Y(19), 0, True, True, False, False, False, False
  532.                 End With
  533.                 GrChild.Closed = True
  534.                 GrChild.Properties("PenWidth") = 0.02
  535.                 GrChild.Properties("PenColor") = PColor
  536.                 GrChild.Properties("BrushStyle") = "Solid"
  537.                 GrChild.Properties("BrushColor") = BColor
  538.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  539.                           GrChild.Cosmetic = True
  540.                 With GrChild.Vertices
  541.                     .Add X(19), Y(19), 0, True, True, False, False, False, False
  542.                     .Add X(20), Y(20), 0, True, True, False, False, False, False
  543.                     .Add X(21), Y(21), 0, False, True, False, False, False, False
  544.                     .Add X(22), Y(22), 0, True, True, False, False, False, False
  545.                 End With
  546.                 GrChild.Properties("PenWidth") = 0.02
  547.                 GrChild.Properties("PenColor") = PColor
  548.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  549.                           GrChild.Cosmetic = True
  550.                 With GrChild.Vertices
  551.                     .Add X(25), Y(25), 0, True, True, False, False, False, False
  552.                     .Add X(23), Y(23), 0, True, True, False, False, False, False
  553.                     .Add X(26), Y(26), 0, False, True, False, False, False, False
  554.                     .Add X(24), Y(24), 0, True, True, False, False, False, False
  555.                 End With
  556.                 GrChild.Properties("PenColor") = PColor
  557.             End If
  558.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  559.                     GrChild.Cosmetic = True
  560.             With GrChild.Vertices
  561.                 .Add X(1), Y(1), 0, True, True, False, False, False, False
  562.                 .Add X(3), Y(3), 0, True, True, False, False, False, False
  563.                 .Add X(5), Y(5), 0, True, True, False, False, False, False
  564.                 .Add X(7), Y(7), 0, True, True, False, False, False, False
  565.                 .Add X(8), Y(8), 0, True, True, False, False, False, False
  566.                 .Add X(6), Y(6), 0, True, True, False, False, False, False
  567.                 .Add X(4), Y(4), 0, True, True, False, False, False, False
  568.                 .Add X(2), Y(2), 0, True, True, False, False, False, False
  569.                 .Add X(1), Y(1), 0, True, True, False, False, False, False
  570.             End With
  571.             GrChild.Closed = True
  572.             GrChild.Properties("PenWidth") = 0.02
  573.             GrChild.Properties("PenColor") = PColor
  574.             GrChild.Properties("BrushStyle") = "Solid"
  575.             GrChild.Properties("BrushColor") = BColor
  576.              Set GrChild = Gr.Graphics.Add(gkGraphic)
  577.                        GrChild.Cosmetic = True
  578.              With GrChild.Vertices
  579.                  .Add X(9), Y(9), 0, True, True, False, False, False, False
  580.                  .Add X(11), Y(11), 0, True, True, False, False, False, False
  581.                  .Add X(10), Y(10), 0, False, True, False, False, False, False
  582.                  .Add X(12), Y(12), 0, True, True, False, False, False, False
  583.              End With
  584.              GrChild.Properties("PenWidth") = 0.02
  585.             GrChild.Properties("PenColor") = PColor
  586.             '14
  587.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(3), Y(3), 0#, X(13), Y(13), 0#, X(9), Y(9), 0#)
  588.                        GrChild.Cosmetic = True
  589.              GrChild.Properties("PenWidth") = 0.02
  590.             GrChild.Properties("PenColor") = PColor
  591.             '15
  592.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(9), Y(9), 0#, X(17), Y(17), 0#, X(10), Y(10), 0#)
  593.                        GrChild.Cosmetic = True
  594.              GrChild.Properties("PenWidth") = 0.02
  595.             GrChild.Properties("PenColor") = PColor
  596.             '16
  597.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(10), Y(10), 0#, X(14), Y(14), 0#, X(4), Y(4), 0#)
  598.                        GrChild.Cosmetic = True
  599.              GrChild.Properties("PenWidth") = 0.02
  600.             GrChild.Properties("PenColor") = PColor
  601.                        
  602.             '14
  603.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(5), Y(5), 0#, X(15), Y(15), 0#, X(11), Y(11), 0#)
  604.                        GrChild.Cosmetic = True
  605.              GrChild.Properties("PenWidth") = 0.02
  606.              GrChild.Properties("PenColor") = PColor
  607.            '15
  608.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(11), Y(11), 0#, X(18), Y(18), 0#, X(12), Y(12), 0#)
  609.                        GrChild.Cosmetic = True
  610.              GrChild.Properties("PenWidth") = 0.02
  611.             GrChild.Properties("PenColor") = PColor
  612.             '16
  613.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(12), Y(12), 0#, X(16), Y(16), 0#, X(6), Y(6), 0#)
  614.                        GrChild.Cosmetic = True
  615.              GrChild.Properties("PenWidth") = 0.02
  616.             GrChild.Properties("PenColor") = PColor
  617.         End If
  618. '-------------------------------------------------------------
  619.         If ViewN = "Top" Then
  620. ' View Top
  621.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  622.                       GrChild.Cosmetic = True
  623.             With GrChild.Vertices
  624.                 For i = 0 To 6
  625.                     x0(i) = D / 2 * Cos(Pi / 3 * i)
  626.                     y0(i) = D / 2 * Sin(Pi / 3 * i)
  627.                     X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  628.                     Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  629.                    .Add X(i), Y(i), 0, True, True, False, False, False, False
  630.                 Next i
  631.             End With
  632.              GrChild.Closed = True
  633.              GrChild.Properties("PenWidth") = 0.02
  634.             GrChild.Properties("PenColor") = PColor
  635.              GrChild.Properties("BrushStyle") = "Solid"
  636.              GrChild.Properties("BrushColor") = BColor
  637.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + D / 2 * Sin(Pi / 3), Y00, 0)
  638.                       GrChild.Cosmetic = True
  639.              GrChild.Properties("PenWidth") = 0.02
  640.              GrChild.Properties("PenColor") = PColor
  641.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2, Y00, 0)
  642.                       GrChild.Cosmetic = True
  643.              GrChild.Properties("PenWidth") = 0.02
  644.             GrChild.Properties("PenColor") = PColor
  645.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2 - del, Y00, 0)
  646.                       GrChild.Cosmetic = True
  647.              GrChild.Properties("PenWidth") = 0.02
  648.             GrChild.Properties("PenColor") = PColor
  649.             x0(7) = D / 2
  650.             y0(7) = 0
  651.             X(7) = X00 + x0(7) * Calp - y0(7) * Salp
  652.             Y(7) = Y00 + x0(7) * Salp + y0(7) * Calp
  653.             
  654.            With Gr.Vertices
  655.                 .Item(1).X = X(7)
  656.                 .Item(1).Y = Y(7)
  657.             End With
  658.         End If
  659. End Sub
  660.  
  661.  
  662.  
  663. Private Sub LowCrownNut(Gr As Graphic, dd As Double, LThread As Double)
  664. Dim D#, H#, S#, K#
  665.         D = 1.63 * dd
  666.         H = 0.72 * dd
  667.         S = D * Cos(Pi / 6)
  668.         K = D / 2 * (1 - Cos(Pi / 6)) * Tan(Pi / 6)
  669. Dim Q#
  670.         Q = 1.55 * dd '1.55
  671. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  672. Dim Salp#, Calp#, L#
  673. Dim X00#, Y00#, X01#, Y01#
  674.         With Gr.Vertices
  675.             X00 = .Item(0).X
  676.             Y00 = .Item(0).Y
  677.             X01 = .Item(1).X
  678.             Y01 = .Item(1).Y
  679.             L = Sqr((X01 - X00) * (X01 - X00) + (Y01 - Y00) * (Y01 - Y00))
  680.             Salp = (Y01 - Y00) / L
  681.             Calp = (X01 - X00) / L
  682.         End With
  683.         If Abs(H - L) > 0.0001 Then
  684.             X01 = X00 + H * Calp
  685.             Y01 = Y00 + H * Salp
  686.             With Gr.Vertices
  687.                 .Item(1).X = X01
  688.                 .Item(1).Y = Y01
  689.                 L = H
  690.             End With
  691.         End If
  692. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  693.  
  694. Dim x0(19)
  695. Dim y0(19)
  696. Dim X(19)
  697. Dim Y(19)
  698.        
  699.        x0(1) = 0#
  700.        y0(1) = S / 2#
  701.        
  702.        x0(2) = x0(1)
  703.        y0(2) = -y0(1)
  704.        
  705.        x0(3) = K
  706.        y0(3) = D / 2#
  707.        
  708.        x0(4) = x0(3)
  709.        y0(4) = -y0(3)
  710.        
  711.        x0(5) = H - K
  712.        y0(5) = D / 2
  713.        
  714.        x0(6) = x0(5)
  715.        y0(6) = -y0(5)
  716.               
  717.        x0(7) = H
  718.        y0(7) = S / 2#
  719.        
  720.        x0(8) = x0(7)
  721.        y0(8) = -y0(7)
  722.        
  723.        x0(9) = x0(3)
  724.        y0(9) = D / 4
  725.        
  726.        x0(10) = x0(9)
  727.        y0(10) = -y0(9)
  728.        
  729.        x0(11) = x0(5)
  730.        y0(11) = D / 4#
  731.        
  732.        x0(12) = x0(11)
  733.        y0(12) = -y0(11)
  734.        
  735.        x0(13) = 0#
  736.        y0(13) = 3 * D / 8
  737.        
  738.        x0(14) = x0(13)
  739.        y0(14) = -y0(13)
  740.        
  741.        x0(15) = H
  742.        y0(15) = 3 * D / 8
  743.        
  744.        x0(16) = x0(15)
  745.        y0(16) = -y0(15)
  746.        
  747.        x0(17) = 0
  748.        y0(17) = 0
  749.        
  750.        x0(18) = H
  751.        y0(18) = 0#
  752.        
  753.        x0(19) = Q
  754.        y0(19) = 0#
  755.        
  756.        
  757. Dim i%
  758.        For i = 1 To 19
  759.           X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  760.           Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  761.        Next i
  762. Dim GrChild As Graphic
  763.             'Add child Graphics
  764.         If ViewN = "Front" Then
  765.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  766.                       GrChild.Cosmetic = True
  767.             With GrChild.Vertices
  768.                 .Add X(1), Y(1), 0, True, True, False, False, False, False
  769.                 .Add X(3), Y(3), 0, True, True, False, False, False, False
  770.                 .Add X(5), Y(5), 0, True, True, False, False, False, False
  771.                 .Add X(7), Y(7), 0, True, True, False, False, False, False
  772.                 .Add X(8), Y(8), 0, True, True, False, False, False, False
  773.                 .Add X(6), Y(6), 0, True, True, False, False, False, False
  774.                 .Add X(4), Y(4), 0, True, True, False, False, False, False
  775.                 .Add X(2), Y(2), 0, True, True, False, False, False, False
  776.                 .Add X(1), Y(1), 0, True, True, False, False, False, False
  777.             End With
  778.             GrChild.Closed = True
  779.             GrChild.Properties("PenWidth") = 0.02
  780.             GrChild.Properties("PenColor") = PColor
  781.             GrChild.Properties("BrushStyle") = "Solid"
  782.             GrChild.Properties("BrushColor") = BColor
  783.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  784.                       GrChild.Cosmetic = True
  785.             With GrChild.Vertices
  786.                 .Add X(9), Y(9), 0, True, True, False, False, False, False
  787.                 .Add X(11), Y(11), 0, True, True, False, False, False, False
  788.                 .Add X(10), Y(10), 0, False, True, False, False, False, False
  789.                 .Add X(12), Y(12), 0, True, False, False, False, False, False
  790.             End With
  791.             GrChild.Properties("PenWidth") = 0.02
  792.             GrChild.Properties("PenColor") = PColor
  793.            '14
  794.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(3), Y(3), 0#, X(13), Y(13), 0#, X(9), Y(9), 0#)
  795.                       GrChild.Cosmetic = True
  796.             GrChild.Properties("PenWidth") = 0.02
  797.             GrChild.Properties("PenColor") = PColor
  798.            '15
  799.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(9), Y(9), 0#, X(17), Y(17), 0#, X(10), Y(10), 0#)
  800.                       GrChild.Cosmetic = True
  801.             GrChild.Properties("PenWidth") = 0.02
  802.             GrChild.Properties("PenColor") = PColor
  803.            '16
  804.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(10), Y(10), 0#, X(14), Y(14), 0#, X(4), Y(4), 0#)
  805.                       GrChild.Cosmetic = True
  806.             GrChild.Properties("PenWidth") = 0.02
  807.             GrChild.Properties("PenColor") = PColor
  808.                       
  809.            '14
  810.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(5), Y(5), 0#, X(15), Y(15), 0#, X(11), Y(11), 0#)
  811.                       GrChild.Cosmetic = True
  812.             GrChild.Properties("PenWidth") = 0.02
  813.             GrChild.Properties("PenColor") = PColor
  814.            '15
  815.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(11), Y(11), 0#, X(18), Y(18), 0#, X(12), Y(12), 0#)
  816.                       GrChild.Cosmetic = True
  817.             GrChild.Properties("PenWidth") = 0.02
  818.             GrChild.Properties("PenColor") = PColor
  819.            '16
  820.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(12), Y(12), 0#, X(16), Y(16), 0#, X(6), Y(6), 0#)
  821.                       GrChild.Cosmetic = True
  822.             GrChild.Properties("PenWidth") = 0.02
  823.             GrChild.Properties("PenColor") = PColor
  824.     'Elliptical Arc
  825.             
  826.             Set GrChild = Gr.Application.ActiveDrawing.Graphics.AddArcRotatedElliptical((X(7) + X(8)) / 2, (Y(7) + Y(8)) / 2, 0#, X(19), Y(19), 0#, X(7), Y(7), 0#, -Pi / 2, Pi / 2)
  827.             'Set GrChild = Gr.Graphics.AddArcRotatedElliptical((X(7) + X(8)) / 2, (Y(7) + Y(8)) / 2, 0#, X(19), Y(19), 0#, X(7), Y(7), 0#, -Pi / 2, Pi / 2)
  828.                       'GrChild.Cosmetic = True
  829. Dim GrHatch As Graphic
  830.             Set GrHatch = GrChild.Graphics.AddHatch
  831.                       GrHatch.Cosmetic = True
  832.             GrHatch.Properties("BrushStyle") = "Solid"
  833.             GrHatch.Properties("BrushColor") = BColor
  834.             Gr.Application.ActiveDrawing.Graphics.Remove GrHatch.Index
  835.             Gr.Graphics.AddGraphic GrHatch
  836.             GrChild.Delete
  837.             
  838.             Set GrChild = Gr.Graphics.AddArcRotatedElliptical((X(7) + X(8)) / 2, (Y(7) + Y(8)) / 2, 0#, X(19), Y(19), 0#, X(7), Y(7), 0#, -Pi / 2, Pi / 2)
  839.                       GrChild.Cosmetic = True
  840.             GrChild.Properties("PenWidth") = 0.02
  841.             GrChild.Properties("PenColor") = PColor
  842.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  843.                       GrChild.Cosmetic = True
  844.             With GrChild.Vertices
  845.                 .Add X(7), Y(7), 0, True, True, False, False, False, False
  846.                 .Add X(8), Y(8), 0, True, True, False, False, False, False
  847.             End With
  848.             GrChild.Properties("PenWidth") = 0.02
  849.             GrChild.Properties("PenColor") = PColor
  850.             
  851.         End If
  852.  
  853. '-------------------------------------------------------------
  854. ' View Top
  855.         If ViewN = "Top" Then
  856.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  857.                       GrChild.Cosmetic = True
  858.             With GrChild.Vertices
  859.                 For i = 0 To 6
  860.                     x0(i) = D / 2 * Cos(Pi / 3 * i)
  861.                     y0(i) = D / 2 * Sin(Pi / 3 * i)
  862.                     X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  863.                     Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  864.                    .Add X(i), Y(i), 0, True, True, False, False, False, False
  865.                 Next i
  866.             End With
  867.             GrChild.Closed = True
  868.             GrChild.Properties("PenWidth") = 0.02
  869.             GrChild.Properties("PenColor") = PColor
  870.              GrChild.Properties("BrushStyle") = "Solid"
  871.              GrChild.Properties("BrushColor") = BColor
  872.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + D / 2 * Sin(Pi / 3), Y00, 0)
  873.                       GrChild.Cosmetic = True
  874.              GrChild.Properties("PenWidth") = 0.02
  875.             GrChild.Properties("PenColor") = PColor
  876.             x0(7) = D / 2
  877.             y0(7) = 0
  878.             X(7) = X00 + x0(7) * Calp - y0(7) * Salp
  879.             Y(7) = Y00 + x0(7) * Salp + y0(7) * Calp
  880.             
  881.            With Gr.Vertices
  882.                 .Item(1).X = X(7)
  883.                 .Item(1).Y = Y(7)
  884.             End With
  885.         End If
  886. End Sub
  887.  
  888.  
  889. Private Sub SquareNut(Gr As Graphic, dd As Double, LThread As Double)
  890. Dim D#, H#, S#, K#, del#
  891.         D = 2# * dd
  892.         H = 0.9 * dd
  893.         S = D * Cos(Pi / 4)
  894.         K = 0.5 * (D - S) * Tan(Pi / 6)
  895.         del = 0.15 * dd
  896. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  897. Dim Salp#, Calp#, L#
  898. Dim X00#, Y00#, X01#, Y01#
  899.         With Gr.Vertices
  900.             X00 = .Item(0).X
  901.             Y00 = .Item(0).Y
  902.             X01 = .Item(1).X
  903.             Y01 = .Item(1).Y
  904.             L = Sqr((X01 - X00) * (X01 - X00) + (Y01 - Y00) * (Y01 - Y00))
  905.             Salp = (Y01 - Y00) / L
  906.             Calp = (X01 - X00) / L
  907.         End With
  908.         If Abs(H - L) > 0.0001 Then
  909.             X01 = X00 + H * Calp
  910.             Y01 = Y00 + H * Salp
  911.             With Gr.Vertices
  912.                 .Item(1).X = X01
  913.                 .Item(1).Y = Y01
  914.                 L = H
  915.             End With
  916.         End If
  917. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  918.  
  919. Dim x0(22)
  920. Dim y0(22)
  921. Dim X(22)
  922. Dim Y(22)
  923.        
  924.        x0(1) = 0#
  925.        y0(1) = S / 2#
  926.        
  927.        x0(2) = x0(1)
  928.        y0(2) = -y0(1)
  929.        
  930.        x0(3) = K
  931.        y0(3) = D / 2#
  932.        
  933.        x0(4) = x0(3)
  934.        y0(4) = -y0(3)
  935.        
  936.        x0(5) = H - K
  937.        y0(5) = D / 2
  938.        
  939.        x0(6) = x0(5)
  940.        y0(6) = -y0(5)
  941.               
  942.        x0(7) = H
  943.        y0(7) = S / 2#
  944.        
  945.        x0(8) = x0(7)
  946.        y0(8) = -y0(7)
  947.        
  948.        x0(9) = x0(3)
  949.        y0(9) = 0#
  950.        
  951.        x0(10) = x0(5)
  952.        y0(10) = 0#
  953.        
  954.        x0(11) = 0
  955.        y0(11) = D / 4#
  956.        
  957.        x0(12) = x0(11)
  958.        y0(12) = -y0(11)
  959.        
  960.        x0(13) = H
  961.        y0(13) = D / 4
  962.        
  963.        x0(14) = x0(13)
  964.        y0(14) = -y0(13)
  965.        
  966. ' Thread
  967.        x0(15) = H
  968.        y0(15) = dd / 2
  969.        
  970.        x0(16) = x0(15)
  971.        y0(16) = -y0(15)
  972.        
  973.        x0(17) = H + LThread - del
  974.        y0(17) = dd / 2
  975.        
  976.        x0(18) = x0(17)
  977.        y0(18) = -y0(17)
  978.        
  979.        x0(19) = H + LThread
  980.        y0(19) = dd / 2 - del
  981.        
  982.        x0(20) = x0(19)
  983.        y0(20) = -y0(19)
  984.        
  985.        x0(21) = H
  986.        y0(21) = dd / 2 - del
  987.        
  988.        x0(22) = x0(21)
  989.        y0(22) = -y0(21)
  990.        
  991.        
  992. Dim i%
  993.        For i = 1 To 22
  994.           X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  995.           Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  996.        Next i
  997. Dim GrChild As Graphic
  998.             'Add child Graphics
  999.         If ViewN = "Front" Then
  1000.             If LThread > 0.01 * dd Then
  1001.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1002.                           GrChild.Cosmetic = True
  1003.                 With GrChild.Vertices
  1004.                     .Add X(15), Y(15), 0, True, True, False, False, False, False
  1005.                     .Add X(17), Y(17), 0, True, True, False, False, False, False
  1006.                     .Add X(19), Y(19), 0, True, True, False, False, False, False
  1007.                     .Add X(20), Y(20), 0, True, True, False, False, False, False
  1008.                     .Add X(18), Y(18), 0, True, True, False, False, False, False
  1009.                     .Add X(16), Y(16), 0, True, True, False, False, False, False
  1010.                     .Add X(15), Y(15), 0, True, True, False, False, False, False
  1011.                 End With
  1012.                 GrChild.Closed = True
  1013.                 GrChild.Properties("PenWidth") = 0.02
  1014.                 GrChild.Properties("PenColor") = PColor
  1015.                 GrChild.Properties("BrushStyle") = "Solid"
  1016.                 GrChild.Properties("BrushColor") = BColor
  1017.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1018.                           GrChild.Cosmetic = True
  1019.                 With GrChild.Vertices
  1020.                     .Add X(17), Y(17), 0, False, True, False, False, False, False
  1021.                     .Add X(18), Y(18), 0, True, True, False, False, False, False
  1022.                 End With
  1023.                 GrChild.Properties("PenWidth") = 0.02
  1024.                 GrChild.Properties("PenColor") = PColor
  1025.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1026.                           GrChild.Cosmetic = True
  1027.                 With GrChild.Vertices
  1028.                     .Add X(21), Y(21), 0, True, True, False, False, False, False
  1029.                     .Add X(19), Y(19), 0, True, True, False, False, False, False
  1030.                     .Add X(22), Y(22), 0, False, True, False, False, False, False
  1031.                     .Add X(20), Y(20), 0, True, True, False, False, False, False
  1032.                 End With
  1033.                 GrChild.Properties("PenColor") = PColor
  1034.             End If
  1035.              Set GrChild = Gr.Graphics.Add(gkGraphic)
  1036.                        GrChild.Cosmetic = True
  1037.              With GrChild.Vertices
  1038.                  .Add X(1), Y(1), 0, True, True, False, False, False, False
  1039.                  .Add X(3), Y(3), 0, True, True, False, False, False, False
  1040.                  .Add X(5), Y(5), 0, True, True, False, False, False, False
  1041.                  .Add X(7), Y(7), 0, True, True, False, False, False, False
  1042.                  .Add X(8), Y(8), 0, True, True, False, False, False, False
  1043.                  .Add X(6), Y(6), 0, True, True, False, False, False, False
  1044.                  .Add X(4), Y(4), 0, True, True, False, False, False, False
  1045.                  .Add X(2), Y(2), 0, True, True, False, False, False, False
  1046.                  .Add X(1), Y(1), 0, True, True, False, False, False, False
  1047.              End With
  1048.              GrChild.Closed = True
  1049.              GrChild.Properties("PenWidth") = 0.02
  1050.             GrChild.Properties("PenColor") = PColor
  1051.             GrChild.Properties("BrushStyle") = "Solid"
  1052.              GrChild.Properties("BrushColor") = BColor
  1053.              Set GrChild = Gr.Graphics.Add(gkGraphic)
  1054.                        GrChild.Cosmetic = True
  1055.              With GrChild.Vertices
  1056.                  .Add X(9), Y(9), 0, True, True, False, False, False, False
  1057.                  .Add X(10), Y(10), 0, True, True, False, False, False, False
  1058.              End With
  1059.              GrChild.Properties("PenWidth") = 0.02
  1060.             GrChild.Properties("PenColor") = PColor
  1061.             '14
  1062.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(3), Y(3), 0#, X(11), Y(11), 0#, X(9), Y(9), 0#)
  1063.                        GrChild.Cosmetic = True
  1064.              GrChild.Properties("PenWidth") = 0.02
  1065.             GrChild.Properties("PenColor") = PColor
  1066.             '15
  1067.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(9), Y(9), 0#, X(12), Y(12), 0#, X(4), Y(4), 0#)
  1068.                        GrChild.Cosmetic = True
  1069.              GrChild.Properties("PenWidth") = 0.02
  1070.             GrChild.Properties("PenColor") = PColor
  1071.             '16
  1072.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(5), Y(5), 0#, X(13), Y(13), 0#, X(10), Y(10), 0#)
  1073.                        GrChild.Cosmetic = True
  1074.              GrChild.Properties("PenWidth") = 0.02
  1075.             GrChild.Properties("PenColor") = PColor
  1076.                        
  1077.             '14
  1078.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(10), Y(10), 0#, X(14), Y(14), 0#, X(6), Y(6), 0#)
  1079.                        GrChild.Cosmetic = True
  1080.              GrChild.Properties("PenWidth") = 0.02
  1081.             GrChild.Properties("PenColor") = PColor
  1082.             '15
  1083.         End If
  1084.  '-------------------------------------------------------------
  1085.         If ViewN = "Top" Then
  1086. ' View Top
  1087.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1088.                       GrChild.Cosmetic = True
  1089.             With GrChild.Vertices
  1090.                 For i = 0 To 4
  1091.                     x0(i) = D / 2 * Cos(Pi / 2 * i)
  1092.                     y0(i) = D / 2 * Sin(Pi / 2 * i)
  1093.                     X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  1094.                     Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  1095.                    .Add X(i), Y(i), 0, True, True, False, False, False, False
  1096.                 Next i
  1097.             End With
  1098.              GrChild.Closed = True
  1099.              GrChild.Properties("PenWidth") = 0.02
  1100.             GrChild.Properties("PenColor") = PColor
  1101.              GrChild.Properties("BrushStyle") = "Solid"
  1102.              GrChild.Properties("BrushColor") = BColor
  1103.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + D / 2 * Sin(Pi / 4), Y00, 0)
  1104.                       GrChild.Cosmetic = True
  1105.              GrChild.Properties("PenWidth") = 0.02
  1106.             GrChild.Properties("PenColor") = PColor
  1107.              Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2, Y00, 0)
  1108.                       GrChild.Cosmetic = True
  1109.              GrChild.Properties("PenWidth") = 0.02
  1110.             GrChild.Properties("PenColor") = PColor
  1111.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2 - del, Y00, 0)
  1112.                       GrChild.Cosmetic = True
  1113.              GrChild.Properties("PenWidth") = 0.02
  1114.             GrChild.Properties("PenColor") = PColor
  1115.             x0(5) = D / 2
  1116.             y0(5) = 0
  1117.             X(5) = X00 + x0(5) * Calp - y0(5) * Salp
  1118.             Y(5) = Y00 + x0(5) * Salp + y0(5) * Calp
  1119.             
  1120.            With Gr.Vertices
  1121.                 .Item(1).X = X(5)
  1122.                 .Item(1).Y = Y(5)
  1123.             End With
  1124.         End If
  1125. End Sub
  1126.  
  1127. Private Sub HexFlangeNut(Gr As Graphic, dd As Double, LThread As Double)
  1128. Dim D#, Dw#, C#, K#, K1#, E#, Di#, del#
  1129.         D = 1.7 * dd
  1130.         Dw = 1.96 * dd
  1131.         C = 0.15 * dd
  1132.         K = 1# * dd
  1133.         K1 = 0.43 * dd
  1134.         E = (K - K1) * 0.85
  1135.         Di = D * Sin(Pi / 3#)
  1136.         del = 0.15 * dd
  1137. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1138. Dim Salp#, Calp#, L#
  1139. Dim X00#, Y00#, X01#, Y01#
  1140.         With Gr.Vertices
  1141.             X00 = .Item(0).X
  1142.             Y00 = .Item(0).Y
  1143.             X01 = .Item(1).X
  1144.             Y01 = .Item(1).Y
  1145.             L = Sqr((X01 - X00) * (X01 - X00) + (Y01 - Y00) * (Y01 - Y00))
  1146.             Salp = (Y01 - Y00) / L
  1147.             Calp = (X01 - X00) / L
  1148.         End With
  1149.         If Abs(K - L) > 0.0001 Then
  1150.             X01 = X00 + K * Calp
  1151.             Y01 = Y00 + K * Salp
  1152.             With Gr.Vertices
  1153.                 .Item(1).X = X01
  1154.                 .Item(1).Y = Y01
  1155.                 L = K
  1156.             End With
  1157.         End If
  1158. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1159.  
  1160. Dim x0(25)
  1161. Dim y0(25)
  1162. Dim X(25)
  1163. Dim Y(25)
  1164.        
  1165.        x0(1) = 0#
  1166.        y0(1) = Dw / 2#
  1167.        
  1168.        x0(2) = x0(1)
  1169.        y0(2) = -y0(1)
  1170.        
  1171.        x0(3) = C
  1172.        y0(3) = Dw / 2#
  1173.        
  1174.        x0(4) = x0(3)
  1175.        y0(4) = -y0(3)
  1176.        
  1177.        x0(5) = K1
  1178.        y0(5) = D / 2
  1179.        
  1180.        x0(6) = x0(5)
  1181.        y0(6) = -y0(5)
  1182.               
  1183.        x0(7) = K1 + E
  1184.        y0(7) = D / 2#
  1185.        
  1186.        x0(8) = x0(7)
  1187.        y0(8) = -y0(7)
  1188.        
  1189.        x0(9) = K
  1190.        y0(9) = Di / 2
  1191.        
  1192.        x0(10) = x0(9)
  1193.        y0(10) = -y0(9)
  1194.        
  1195.        x0(11) = K1
  1196.        y0(11) = D / 4#
  1197.        
  1198.        x0(12) = x0(11)
  1199.        y0(12) = -y0(11)
  1200.        
  1201.        x0(13) = x0(7)
  1202.        y0(13) = y0(11)
  1203.        
  1204.        x0(14) = x0(13)
  1205.        y0(14) = -y0(13)
  1206.        
  1207.        x0(15) = K
  1208.        y0(15) = 3# * D / 8#
  1209.        
  1210.        x0(16) = x0(15)
  1211.        y0(16) = -y0(15)
  1212.        
  1213.        x0(17) = K
  1214.        y0(17) = 0#
  1215.        
  1216. ' Thread
  1217.        x0(18) = K
  1218.        y0(18) = dd / 2
  1219.        
  1220.        x0(19) = x0(18)
  1221.        y0(19) = -y0(18)
  1222.        
  1223.        x0(20) = K + LThread - del
  1224.        y0(20) = dd / 2
  1225.        
  1226.        x0(21) = x0(20)
  1227.        y0(21) = -y0(20)
  1228.        
  1229.        x0(22) = K + LThread
  1230.        y0(22) = dd / 2 - del
  1231.        
  1232.        x0(23) = x0(22)
  1233.        y0(23) = -y0(22)
  1234.        
  1235.        x0(24) = K
  1236.        y0(24) = dd / 2 - del
  1237.        
  1238.        x0(25) = x0(24)
  1239.        y0(25) = -y0(24)
  1240.        
  1241.        
  1242. Dim i%
  1243.        For i = 1 To 25
  1244.           X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  1245.           Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  1246.        Next i
  1247. Dim GrChild As Graphic
  1248.             'Add child Graphics
  1249.         If ViewN = "Front" Then
  1250.             If LThread > 0.01 * dd Then
  1251.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1252.                           GrChild.Cosmetic = True
  1253.                 With GrChild.Vertices
  1254.                     .Add X(18), Y(18), 0, True, True, False, False, False, False
  1255.                     .Add X(20), Y(20), 0, True, True, False, False, False, False
  1256.                     .Add X(22), Y(22), 0, True, True, False, False, False, False
  1257.                     .Add X(23), Y(23), 0, True, True, False, False, False, False
  1258.                     .Add X(21), Y(21), 0, True, True, False, False, False, False
  1259.                     .Add X(19), Y(19), 0, True, True, False, False, False, False
  1260.                     .Add X(18), Y(18), 0, True, True, False, False, False, False
  1261.                 End With
  1262.                 GrChild.Closed = True
  1263.                 GrChild.Properties("PenWidth") = 0.02
  1264.                 GrChild.Properties("PenColor") = PColor
  1265.                 GrChild.Properties("BrushStyle") = "Solid"
  1266.                 GrChild.Properties("BrushColor") = BColor
  1267.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1268.                           GrChild.Cosmetic = True
  1269.                 With GrChild.Vertices
  1270.                     .Add X(20), Y(20), 0, False, True, False, False, False, False
  1271.                     .Add X(21), Y(21), 0, True, True, False, False, False, False
  1272.                 End With
  1273.                 GrChild.Properties("PenWidth") = 0.02
  1274.                 GrChild.Properties("PenColor") = PColor
  1275.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1276.                           GrChild.Cosmetic = True
  1277.                 With GrChild.Vertices
  1278.                     .Add X(24), Y(24), 0, True, True, False, False, False, False
  1279.                     .Add X(22), Y(22), 0, True, True, False, False, False, False
  1280.                     .Add X(25), Y(25), 0, False, True, False, False, False, False
  1281.                     .Add X(23), Y(23), 0, True, True, False, False, False, False
  1282.                 End With
  1283.                 GrChild.Properties("PenColor") = PColor
  1284.             End If
  1285.              Set GrChild = Gr.Graphics.Add(gkGraphic)
  1286.                        GrChild.Cosmetic = True
  1287.              With GrChild.Vertices
  1288.                  .Add X(1), Y(1), 0, True, True, False, False, False, False
  1289.                  .Add X(3), Y(3), 0, True, True, False, False, False, False
  1290.                  .Add X(5), Y(5), 0, True, True, False, False, False, False
  1291.                  .Add X(7), Y(7), 0, True, True, False, False, False, False
  1292.                  .Add X(9), Y(9), 0, True, True, False, False, False, False
  1293.                  .Add X(10), Y(10), 0, True, True, False, False, False, False
  1294.                  .Add X(8), Y(8), 0, True, True, False, False, False, False
  1295.                  .Add X(6), Y(6), 0, True, True, False, False, False, False
  1296.                  .Add X(4), Y(4), 0, True, True, False, False, False, False
  1297.                  .Add X(2), Y(2), 0, True, True, False, False, False, False
  1298.                  .Add X(1), Y(1), 0, True, True, False, False, False, False
  1299.              End With
  1300.              GrChild.Closed = True
  1301.              GrChild.Properties("PenWidth") = 0.02
  1302.             GrChild.Properties("PenColor") = PColor
  1303.              GrChild.Properties("BrushStyle") = "Solid"
  1304.              GrChild.Properties("BrushColor") = BColor
  1305.              Set GrChild = Gr.Graphics.Add(gkGraphic)
  1306.                        GrChild.Cosmetic = True
  1307.              With GrChild.Vertices
  1308.                  .Add X(3), Y(3), 0, True, True, False, False, False, False
  1309.                  .Add X(4), Y(4), 0, True, True, False, False, False, False
  1310.                  .Add X(5), Y(5), 0, False, True, False, False, False, False
  1311.                  .Add X(6), Y(6), 0, True, True, False, False, False, False
  1312.                  .Add X(11), Y(11), 0, False, True, False, False, False, False
  1313.                  .Add X(13), Y(13), 0, True, True, False, False, False, False
  1314.                  .Add X(12), Y(12), 0, False, True, False, False, False, False
  1315.                  .Add X(14), Y(14), 0, True, True, False, False, False, False
  1316.              End With
  1317.              GrChild.Properties("PenWidth") = 0.02
  1318.             GrChild.Properties("PenColor") = PColor
  1319.             '14
  1320.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(7), Y(7), 0#, X(15), Y(15), 0#, X(13), Y(13), 0#)
  1321.                        GrChild.Cosmetic = True
  1322.              GrChild.Properties("PenWidth") = 0.02
  1323.             GrChild.Properties("PenColor") = PColor
  1324.             '15
  1325.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(8), Y(8), 0#, X(16), Y(16), 0#, X(14), Y(14), 0#)
  1326.                        GrChild.Cosmetic = True
  1327.              GrChild.Properties("PenWidth") = 0.02
  1328.             GrChild.Properties("PenColor") = PColor
  1329.             '16
  1330.             Set GrChild = Gr.Graphics.AddArcTriplePoint(X(13), Y(13), 0#, X(17), Y(17), 0#, X(14), Y(14), 0#)
  1331.                        GrChild.Cosmetic = True
  1332.              GrChild.Properties("PenWidth") = 0.02
  1333.             GrChild.Properties("PenColor") = PColor
  1334.         End If
  1335. '-------------------------------------------------------------
  1336. ' View Top
  1337.         If ViewN = "Top" Then
  1338.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + Dw / 2, Y00, 0)
  1339.                       GrChild.Cosmetic = True
  1340.              GrChild.Properties("PenWidth") = 0.02
  1341.             GrChild.Properties("PenColor") = PColor
  1342.              GrChild.Properties("BrushStyle") = "Solid"
  1343.              GrChild.Properties("BrushColor") = BColor
  1344.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1345.                       GrChild.Cosmetic = True
  1346.             With GrChild.Vertices
  1347.                 For i = 0 To 6
  1348.                     x0(i) = D / 2 * Cos(Pi / 3 * i)
  1349.                     y0(i) = D / 2 * Sin(Pi / 3 * i)
  1350.                     X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  1351.                     Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  1352.                    .Add X(i), Y(i), 0, True, True, False, False, False, False
  1353.                 Next i
  1354.             End With
  1355.              GrChild.Closed = True
  1356.              GrChild.Properties("PenWidth") = 0.02
  1357.             GrChild.Properties("PenColor") = PColor
  1358.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + D / 2 * Sin(Pi / 3), Y00, 0)
  1359.                       GrChild.Cosmetic = True
  1360.              GrChild.Properties("PenWidth") = 0.02
  1361.             GrChild.Properties("PenColor") = PColor
  1362.              Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2, Y00, 0)
  1363.                       GrChild.Cosmetic = True
  1364.              GrChild.Properties("PenWidth") = 0.02
  1365.             GrChild.Properties("PenColor") = PColor
  1366.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2 - del, Y00, 0)
  1367.                       GrChild.Cosmetic = True
  1368.              GrChild.Properties("PenWidth") = 0.02
  1369.             GrChild.Properties("PenColor") = PColor
  1370.             x0(7) = D / 2
  1371.             y0(7) = 0
  1372.             X(7) = X00 + x0(7) * Calp - y0(7) * Salp
  1373.             Y(7) = Y00 + x0(7) * Salp + y0(7) * Calp
  1374.             
  1375.            With Gr.Vertices
  1376.                 .Item(1).X = X(7)
  1377.                 .Item(1).Y = Y(7)
  1378.             End With
  1379.         End If
  1380. End Sub
  1381.  
  1382. Private Sub HexSlottedNut(Gr As Graphic, dd As Double, LThread As Double)
  1383. Dim D#, H#, S#, K#, J#, H1#, del#
  1384.         D = 1.84 * dd
  1385.         H = 1# * dd
  1386.         S = D * Cos(Pi / 6)
  1387.         K = D / 2 * (1 - Cos(Pi / 6)) * Tan(Pi / 6)
  1388.         J = 0.3 * dd
  1389.         H1 = 0.3 * dd
  1390.         del = 0.15 * dd
  1391. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1392. Dim Salp#, Calp#, L#
  1393. Dim X00#, Y00#, X01#, Y01#
  1394.         With Gr.Vertices
  1395.             X00 = .Item(0).X
  1396.             Y00 = .Item(0).Y
  1397.             X01 = .Item(1).X
  1398.             Y01 = .Item(1).Y
  1399.             L = Sqr((X01 - X00) * (X01 - X00) + (Y01 - Y00) * (Y01 - Y00))
  1400.             Salp = (Y01 - Y00) / L
  1401.             Calp = (X01 - X00) / L
  1402.         End With
  1403.         If Abs(H - L) > 0.0001 Then
  1404.             X01 = X00 + H * Calp
  1405.             Y01 = Y00 + H * Salp
  1406.             With Gr.Vertices
  1407.                 .Item(1).X = X01
  1408.                 .Item(1).Y = Y01
  1409.                 L = H
  1410.             End With
  1411.         End If
  1412. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1413.  
  1414. Dim x0(41)
  1415. Dim y0(41)
  1416. Dim X(41)
  1417. Dim Y(41)
  1418.        
  1419.        x0(1) = 0#
  1420.        y0(1) = S / 2#
  1421.        
  1422.        x0(2) = x0(1)
  1423.        y0(2) = -y0(1)
  1424.        
  1425.        x0(3) = K
  1426.        y0(3) = D / 2#
  1427.        
  1428.        x0(4) = x0(3)
  1429.        y0(4) = -y0(3)
  1430.        
  1431.        x0(5) = H - K
  1432.        y0(5) = D / 2
  1433.        
  1434.        x0(6) = x0(5)
  1435.        y0(6) = -y0(5)
  1436.               
  1437.        x0(7) = H
  1438.        y0(7) = S / 2#
  1439.        
  1440.        x0(8) = x0(7)
  1441.        y0(8) = -y0(7)
  1442.        
  1443.        x0(9) = x0(3)
  1444.        y0(9) = D / 4
  1445.        
  1446.        x0(10) = x0(9)
  1447.        y0(10) = -y0(9)
  1448.        
  1449.        x0(11) = x0(5)
  1450.        y0(11) = D / 4#
  1451.        
  1452.        x0(12) = x0(11)
  1453.        y0(12) = -y0(11)
  1454.        
  1455.        x0(13) = 0#
  1456.        y0(13) = 3 * D / 8
  1457.        
  1458.        x0(14) = x0(13)
  1459.        y0(14) = -y0(13)
  1460.        
  1461.        x0(15) = H
  1462.        y0(15) = 3 * D / 8
  1463.        
  1464.        x0(16) = x0(15)
  1465.        y0(16) = -y0(15)
  1466.        
  1467.        x0(17) = 0
  1468.        y0(17) = 0
  1469.        
  1470.        x0(18) = H
  1471.        y0(18) = 0#
  1472. '#########################################################
  1473.        x0(19) = H
  1474.        y0(19) = y0(15) + J / 4
  1475.        x0(20) = H
  1476.        y0(20) = y0(15) - J / 4
  1477.  
  1478.        x0(21) = H - H1
  1479.        y0(21) = y0(19)
  1480.        x0(22) = x0(21)
  1481.        y0(22) = y0(20)
  1482.  
  1483.        x0(23) = H - H1 - J / 4
  1484.        y0(23) = y0(15)
  1485. '--------------------------------------------------------
  1486.        x0(24) = H
  1487.        y0(24) = y0(16) + J / 4
  1488.        x0(25) = H
  1489.        y0(25) = y0(16) - J / 4
  1490.  
  1491.        x0(26) = H - H1
  1492.        y0(26) = y0(24)
  1493.        x0(27) = x0(26)
  1494.        y0(27) = y0(25)
  1495.  
  1496.        x0(28) = x0(23)
  1497.        y0(28) = y0(16)
  1498.        
  1499. '--------------------------------------------------------
  1500.        x0(29) = H
  1501.        y0(29) = J / 2
  1502.        x0(30) = H
  1503.        y0(30) = -J / 2
  1504.  
  1505.        x0(31) = x0(21) + J / 4
  1506.        y0(31) = y0(29)
  1507.        x0(32) = x0(21) + J / 4
  1508.        y0(32) = y0(30)
  1509.  
  1510.        x0(33) = x0(23)
  1511.        y0(33) = 0#
  1512.        
  1513. ' Thread
  1514.        x0(34) = H
  1515.        y0(34) = dd / 2
  1516.        
  1517.        x0(35) = x0(34)
  1518.        y0(35) = -y0(34)
  1519.        
  1520.        x0(36) = H + LThread - del
  1521.        y0(36) = dd / 2
  1522.        
  1523.        x0(37) = x0(36)
  1524.        y0(37) = -y0(36)
  1525.        
  1526.        x0(38) = H + LThread
  1527.        y0(38) = dd / 2 - del
  1528.        
  1529.        x0(39) = x0(38)
  1530.        y0(39) = -y0(38)
  1531.        
  1532.        x0(40) = H
  1533.        y0(40) = dd / 2 - del
  1534.        
  1535.        x0(41) = x0(40)
  1536.        y0(41) = -y0(40)
  1537.        
  1538.        
  1539. Dim i%
  1540.        For i = 1 To 41
  1541.           X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  1542.           Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  1543.        Next i
  1544. Dim GrChild As Graphic
  1545.             'Add child Graphics
  1546.         If ViewN = "Front" Then
  1547.             If LThread > 0.01 * dd Then
  1548.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1549.                           GrChild.Cosmetic = True
  1550.                 With GrChild.Vertices
  1551.                     .Add X(34), Y(34), 0, True, True, False, False, False, False
  1552.                     .Add X(36), Y(36), 0, True, True, False, False, False, False
  1553.                     .Add X(38), Y(38), 0, True, True, False, False, False, False
  1554.                     .Add X(39), Y(39), 0, True, True, False, False, False, False
  1555.                     .Add X(37), Y(37), 0, True, True, False, False, False, False
  1556.                     .Add X(35), Y(35), 0, True, True, False, False, False, False
  1557.                     .Add X(34), Y(34), 0, True, True, False, False, False, False
  1558.                 End With
  1559.                 GrChild.Closed = True
  1560.                 GrChild.Properties("PenWidth") = 0.02
  1561.                 GrChild.Properties("PenColor") = PColor
  1562.                 GrChild.Properties("BrushStyle") = "Solid"
  1563.                  GrChild.Properties("BrushColor") = BColor
  1564.                Set GrChild = Gr.Graphics.Add(gkGraphic)
  1565.                           GrChild.Cosmetic = True
  1566.                 With GrChild.Vertices
  1567.                     .Add X(36), Y(36), 0, False, True, False, False, False, False
  1568.                     .Add X(37), Y(37), 0, True, True, False, False, False, False
  1569.                 End With
  1570.                 GrChild.Properties("PenWidth") = 0.02
  1571.                 GrChild.Properties("PenColor") = PColor
  1572.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1573.                           GrChild.Cosmetic = True
  1574.                 With GrChild.Vertices
  1575.                     .Add X(40), Y(40), 0, True, True, False, False, False, False
  1576.                     .Add X(38), Y(38), 0, True, True, False, False, False, False
  1577.                     .Add X(41), Y(41), 0, False, True, False, False, False, False
  1578.                     .Add X(39), Y(39), 0, True, True, False, False, False, False
  1579.                 End With
  1580.                 GrChild.Properties("PenColor") = PColor
  1581.             End If
  1582.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1583.                       GrChild.Cosmetic = True
  1584.             With GrChild.Vertices
  1585.                 .Add X(1), Y(1), 0, True, True, False, False, False, False
  1586.                 .Add X(3), Y(3), 0, True, True, False, False, False, False
  1587.                 .Add X(5), Y(5), 0, True, True, False, False, False, False
  1588.                 .Add X(7), Y(7), 0, True, True, False, False, False, False
  1589.                 .Add X(8), Y(8), 0, True, True, False, False, False, False
  1590.                 .Add X(6), Y(6), 0, True, True, False, False, False, False
  1591.                 .Add X(4), Y(4), 0, True, True, False, False, False, False
  1592.                 .Add X(2), Y(2), 0, True, True, False, False, False, False
  1593.                 .Add X(1), Y(1), 0, True, True, False, False, False, False
  1594.             End With
  1595.             GrChild.Closed = True
  1596.             GrChild.Properties("PenWidth") = 0.02
  1597.             GrChild.Properties("PenColor") = PColor
  1598.             GrChild.Properties("BrushStyle") = "Solid"
  1599.             GrChild.Properties("BrushColor") = BColor
  1600.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1601.                       GrChild.Cosmetic = True
  1602.             With GrChild.Vertices
  1603.                 .Add X(9), Y(9), 0, True, True, False, False, False, False
  1604.                 .Add X(11), Y(11), 0, True, True, False, False, False, False
  1605.                 .Add X(10), Y(10), 0, False, True, False, False, False, False
  1606.                 .Add X(12), Y(12), 0, True, True, False, False, False, False
  1607.             End With
  1608.             GrChild.Properties("PenWidth") = 0.02
  1609.             GrChild.Properties("PenColor") = PColor
  1610.            '14
  1611.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(3), Y(3), 0#, X(13), Y(13), 0#, X(9), Y(9), 0#)
  1612.                       GrChild.Cosmetic = True
  1613.             GrChild.Properties("PenWidth") = 0.02
  1614.             GrChild.Properties("PenColor") = PColor
  1615.            '15
  1616.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(9), Y(9), 0#, X(17), Y(17), 0#, X(10), Y(10), 0#)
  1617.                       GrChild.Cosmetic = True
  1618.             GrChild.Properties("PenWidth") = 0.02
  1619.             GrChild.Properties("PenColor") = PColor
  1620.            '16
  1621.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(10), Y(10), 0#, X(14), Y(14), 0#, X(4), Y(4), 0#)
  1622.                       GrChild.Cosmetic = True
  1623.             GrChild.Properties("PenWidth") = 0.02
  1624.             GrChild.Properties("PenColor") = PColor
  1625.                       
  1626.            '14
  1627.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(5), Y(5), 0#, X(15), Y(15), 0#, X(11), Y(11), 0#)
  1628.                       GrChild.Cosmetic = True
  1629.             GrChild.Properties("PenWidth") = 0.02
  1630.             GrChild.Properties("PenColor") = PColor
  1631.            '15
  1632.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(11), Y(11), 0#, X(18), Y(18), 0#, X(12), Y(12), 0#)
  1633.                       GrChild.Cosmetic = True
  1634.             GrChild.Properties("PenWidth") = 0.02
  1635.             GrChild.Properties("PenColor") = PColor
  1636.            '16
  1637.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(12), Y(12), 0#, X(16), Y(16), 0#, X(6), Y(6), 0#)
  1638.                       GrChild.Cosmetic = True
  1639.             GrChild.Properties("PenWidth") = 0.02
  1640.             GrChild.Properties("PenColor") = PColor
  1641.     '-------------------------------------------------------------
  1642.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1643.                       GrChild.Cosmetic = True
  1644.              With GrChild.Vertices
  1645.                 .Add X(19), Y(19), 0, True, True, False, False, False, False
  1646.                 .Add X(21), Y(21), 0, True, True, False, False, False, False
  1647.             End With
  1648.             GrChild.Properties("PenColor") = PColor
  1649.             GrChild.Properties("PenWidth") = 0.02
  1650.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1651.                       GrChild.Cosmetic = True
  1652.              With GrChild.Vertices
  1653.                 .Add X(20), Y(20), 0, True, True, False, False, False, False
  1654.                 .Add X(22), Y(22), 0, True, True, False, False, False, False
  1655.             End With
  1656.             GrChild.Properties("PenWidth") = 0.02
  1657.             GrChild.Properties("PenColor") = PColor
  1658.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(21), Y(21), 0#, X(23), Y(23), 0#, X(22), Y(22), 0#)
  1659.                       GrChild.Cosmetic = True
  1660.             GrChild.Properties("PenWidth") = 0.02
  1661.             GrChild.Properties("PenColor") = PColor
  1662.     '-------------------------------------------------------------
  1663.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1664.                       GrChild.Cosmetic = True
  1665.              With GrChild.Vertices
  1666.                 .Add X(24), Y(24), 0, True, True, False, False, False, False
  1667.                 .Add X(26), Y(26), 0, True, True, False, False, False, False
  1668.             End With
  1669.             GrChild.Properties("PenWidth") = 0.02
  1670.             GrChild.Properties("PenColor") = PColor
  1671.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1672.                       GrChild.Cosmetic = True
  1673.              With GrChild.Vertices
  1674.                 .Add X(25), Y(25), 0, True, True, False, False, False, False
  1675.                 .Add X(27), Y(27), 0, True, True, False, False, False, False
  1676.             End With
  1677.             GrChild.Properties("PenWidth") = 0.02
  1678.             GrChild.Properties("PenColor") = PColor
  1679.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(26), Y(26), 0#, X(28), Y(28), 0#, X(27), Y(27), 0#)
  1680.                       GrChild.Cosmetic = True
  1681.             GrChild.Properties("PenWidth") = 0.02
  1682.             GrChild.Properties("PenColor") = PColor
  1683.     '-------------------------------------------------------------
  1684.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1685.                       GrChild.Cosmetic = True
  1686.              With GrChild.Vertices
  1687.                 .Add X(29), Y(29), 0, True, True, False, False, False, False
  1688.                 .Add X(31), Y(31), 0, True, True, False, False, False, False
  1689.             End With
  1690.             GrChild.Properties("PenWidth") = 0.02
  1691.             GrChild.Properties("PenColor") = PColor
  1692.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1693.                       GrChild.Cosmetic = True
  1694.              With GrChild.Vertices
  1695.                 .Add X(30), Y(30), 0, True, True, False, False, False, False
  1696.                 .Add X(32), Y(32), 0, True, True, False, False, False, False
  1697.             End With
  1698.             GrChild.Properties("PenWidth") = 0.02
  1699.             GrChild.Properties("PenColor") = PColor
  1700.            Set GrChild = Gr.Graphics.AddArcTriplePoint(X(31), Y(31), 0#, X(33), Y(33), 0#, X(32), Y(32), 0#)
  1701.                       GrChild.Cosmetic = True
  1702.             GrChild.Properties("PenWidth") = 0.02
  1703.             GrChild.Properties("PenColor") = PColor
  1704.         End If
  1705.                 
  1706.         If ViewN = "Top" Then
  1707. ' View Top
  1708.             Set GrChild = Gr.Graphics.Add(gkGraphic)
  1709.                       GrChild.Cosmetic = True
  1710.             With GrChild.Vertices
  1711.                 For i = 0 To 6
  1712.                     x0(i) = D / 2 * Cos(Pi / 3 * i)
  1713.                     y0(i) = D / 2 * Sin(Pi / 3 * i)
  1714.                     X(i) = X00 + x0(i) * Calp - y0(i) * Salp
  1715.                     Y(i) = Y00 + x0(i) * Salp + y0(i) * Calp
  1716.                    .Add X(i), Y(i), 0, True, True, False, False, False, False
  1717.                 Next i
  1718.             End With
  1719.              GrChild.Closed = True
  1720.              GrChild.Properties("PenWidth") = 0.02
  1721.             GrChild.Properties("PenColor") = PColor
  1722.              GrChild.Properties("BrushStyle") = "Solid"
  1723.              GrChild.Properties("BrushColor") = BColor
  1724.              Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2, Y00, 0)
  1725.                       GrChild.Cosmetic = True
  1726.              GrChild.Properties("PenWidth") = 0.02
  1727.             GrChild.Properties("PenColor") = PColor
  1728.             Set GrChild = Gr.Graphics.AddCircleCenterAndPoint(X00, Y00, 0, X00 + dd / 2 - del, Y00, 0)
  1729.                       GrChild.Cosmetic = True
  1730.              GrChild.Properties("PenWidth") = 0.02
  1731.             GrChild.Properties("PenColor") = PColor
  1732.             x0(7) = D / 2
  1733.             y0(7) = 0
  1734.             X(7) = X00 + x0(7) * Calp - y0(7) * Salp
  1735.             Y(7) = Y00 + x0(7) * Salp + y0(7) * Calp
  1736.             
  1737.            With Gr.Vertices
  1738.                 .Item(1).X = X(7)
  1739.                 .Item(1).Y = Y(7)
  1740.             End With
  1741. Dim x1#, y1#, x2#, y2#, x3#, y3#, x4#, y4#, x5#, y5#, x6#, y6#, x7#, y7#
  1742.             x1 = D / 2
  1743.             y1 = 0#
  1744.             x2 = x1 - D / 4 * Sin(Pi / 6)
  1745.             y2 = y1 + D / 4 * Sin(Pi / 3)
  1746.             x4 = x2 + J / 2 * Sin(Pi / 6)
  1747.             y4 = y2 - J / 2 * Sin(Pi / 3)
  1748.             x5 = x2 - J / 2 * Sin(Pi / 6)
  1749.             y5 = y2 + J / 2 * Sin(Pi / 3)
  1750. Dim L1#, hx#
  1751.             
  1752.             L1 = Sqr((x4 - x5) * (x4 - x5) + (y4 - y5) * (y4 - y5))
  1753.             hx = Sqr(dd * dd / 4 - L1 * L1 / 4)
  1754.             x3 = x2 - (D / 2 * Sin(Pi / 3) - hx) * Sin(Pi / 3)
  1755.             y3 = y2 - (D / 2 * Sin(Pi / 3) - hx) * Sin(Pi / 6)
  1756.             x6 = x3 + J / 2 * Sin(Pi / 6)
  1757.             y6 = y3 - J / 2 * Sin(Pi / 3)
  1758.             x7 = x3 - J / 2 * Sin(Pi / 6)
  1759.             y7 = y3 + J / 2 * Sin(Pi / 3)
  1760. Dim x41#, y41#, x51#, y51#, x61#, y61#, x71#, y71#
  1761. Dim x42#, y42#, x52#, y52#, x62#, y62#, x72#, y72#
  1762. Dim xc#, yc#, xc1#, yc1#, xc2#, yc2#, xc3#, yc3#
  1763.             For i = 0 To 5
  1764.                 x41 = x4 * Cos(Pi / 3 * i) - y4 * Sin(Pi / 3 * i)
  1765.                 y41 = x4 * Sin(Pi / 3 * i) + y4 * Cos(Pi / 3 * i)
  1766.                 x51 = x5 * Cos(Pi / 3 * i) - y5 * Sin(Pi / 3 * i)
  1767.                 y51 = x5 * Sin(Pi / 3 * i) + y5 * Cos(Pi / 3 * i)
  1768.                 x61 = x6 * Cos(Pi / 3 * i) - y6 * Sin(Pi / 3 * i)
  1769.                 y61 = x6 * Sin(Pi / 3 * i) + y6 * Cos(Pi / 3 * i)
  1770.                 x71 = x7 * Cos(Pi / 3 * i) - y7 * Sin(Pi / 3 * i)
  1771.                 y71 = x7 * Sin(Pi / 3 * i) + y7 * Cos(Pi / 3 * i)
  1772.                 x42 = X00 + x41 * Calp - y41 * Salp
  1773.                 y42 = Y00 + x41 * Salp + y41 * Calp
  1774.                 x52 = X00 + x51 * Calp - y51 * Salp
  1775.                 y52 = Y00 + x51 * Salp + y51 * Calp
  1776.                 x62 = X00 + x61 * Calp - y61 * Salp
  1777.                 y62 = Y00 + x61 * Salp + y61 * Calp
  1778.                 x72 = X00 + x71 * Calp - y71 * Salp
  1779.                 y72 = Y00 + x71 * Salp + y71 * Calp
  1780.                 Set GrChild = Gr.Graphics.Add(gkGraphic)
  1781.                           GrChild.Cosmetic = True
  1782.                 With GrChild.Vertices
  1783.                    .Add x42, y42, 0, True, True, False, False, False, False
  1784.                    .Add x62, y62, 0, True, True, False, False, False, False
  1785.                    .Add x52, y52, 0, False, True, False, False, False, False
  1786.                    .Add x72, y72, 0, True, True, False, False, False, False
  1787.                 End With
  1788.                 GrChild.Properties("PenWidth") = 0.02
  1789.                 GrChild.Properties("PenColor") = PColor
  1790.                xc1 = x42
  1791.                 yc1 = y42
  1792.                 xc = D / 2 * Sin(Pi / 3) * Cos(Pi / 3 * i)
  1793.                 yc = D / 2 * Sin(Pi / 3) * Sin(Pi / 3 * i)
  1794.                 xc2 = X00 + xc * Calp - yc * Salp
  1795.                 yc2 = Y00 + xc * Salp + yc * Calp
  1796.                 x41 = x4 * Cos(Pi / 3 * i) + y4 * Sin(Pi / 3 * i)
  1797.                 y41 = x4 * Sin(Pi / 3 * i) - y4 * Cos(Pi / 3 * i)
  1798.                 xc3 = X00 + x41 * Calp - y41 * Salp
  1799.                 yc3 = Y00 + x41 * Salp + y41 * Calp
  1800.                 Set GrChild = Gr.Graphics.AddArcTriplePoint(xc1, yc1, 0, xc2, yc2, 0, xc3, yc3, 0)
  1801.                           GrChild.Cosmetic = True
  1802.                 GrChild.Properties("PenWidth") = 0.02
  1803.                 GrChild.Properties("PenColor") = PColor
  1804.             Next i
  1805.         End If
  1806. End Sub
  1807.  
  1808.